package com.haoshuang.zhouzhoubang.ui.page.order.take.preview

import android.content.Context
import android.os.Bundle
import com.gyf.immersionbar.ktx.immersionBar
import com.haoshuang.zhouzhoubang.databinding.ActivityTakeOrderPreviewBinding
import com.mufeng.libs.base.BaseVMActivity
import com.mufeng.libs.utils.ktx.getString
import com.mufeng.libs.utils.view.click
import com.mufeng.libs.utils.startPage
import com.mufeng.libs.utils.view.load

/**
 *  订单预览
 */
class TakeOrderPreviewActivity :
    BaseVMActivity<TakeOrderPreviewViewModel, ActivityTakeOrderPreviewBinding>() {

    companion object {
        fun launch(
            context: Context,
            province: String,
            city: String,
            area: String,
            address: String,
            houseNumber: String,
            phoneNumber: String,
            customerName: String,
            serviceDay: String,
            serviceTime: String,
            serviceImage: String,
            serviceName: String,
            serviceSuk: String,
            servicePrice: String,
            increasedAmount: String,
            discountAmount: String,
            remark: String,
            key_areas: String,
        ) {
            context.startPage<TakeOrderPreviewActivity>(
                "province" to province,
                "city" to city,
                "area" to area,
                "address" to address,
                "houseNumber" to houseNumber,
                "phoneNumber" to phoneNumber,
                "customerName" to customerName,
                "serviceDay" to serviceDay,
                "serviceTime" to serviceTime,
                "serviceImage" to serviceImage,
                "serviceName" to serviceName,
                "serviceSuk" to serviceSuk,
                "servicePrice" to servicePrice,
                "increasedAmount" to increasedAmount,
                "discountAmount" to discountAmount,
                "remark" to remark,
                "key_areas" to key_areas
            )
        }
    }

    private val province: String by lazy { intent.getString("province") }
    private val city: String by lazy { intent.getString("city") }
    private val area: String by lazy { intent.getString("area") }
    private val address: String by lazy { intent.getString("address") }
    private val houseNumber: String by lazy { intent.getString("houseNumber") }
    private val phoneNumber: String by lazy { intent.getString("phoneNumber") }
    private val customerName: String by lazy { intent.getString("customerName") }
    private val serviceDay: String by lazy { intent.getString("serviceDay") }
    private val serviceTime: String by lazy { intent.getString("serviceTime") }
    private val serviceImage: String by lazy { intent.getString("serviceImage") }
    private val serviceName: String by lazy { intent.getString("serviceName") }
    private val serviceSuk: String by lazy { intent.getString("serviceSuk") }
    private val servicePrice: String by lazy { intent.getString("servicePrice", "0.00") }
    private val increasedAmount: String by lazy { intent.getString("increasedAmount", "0.00") }
    private val discountAmount: String by lazy { intent.getString("discountAmount", "0.00") }
    private val remark: String by lazy { intent.getString("remark") }
    private val key_areas: String by lazy { intent.getString("key_areas") }

    override fun initView(savedInstanceState: Bundle?) {

        binding.apply {
            ivBack.click { finish() }
            tvBack.click { finish() }
            tvCreate.click {
                setResult(200)
                finish()
            }

            tvAddress.text = "$province$city$area$address$houseNumber"
            tvPhone.text = phoneNumber
            tvServiceTime.text = "$serviceDay $serviceTime"
            rivImage.load(serviceImage)
            tvServiceName.text = serviceName
            tvSuk.text = serviceSuk
            tvPrice.text = servicePrice
            tvCustomerName.text = customerName
            tvIncreasedAmount.text = increasedAmount
            tvDiscountAmount.text = discountAmount
            tvRemark.text = remark
        }

    }

    override fun initImmersionBar() {
        immersionBar {
            transparentStatusBar()
            titleBarMarginTop(binding.flTitleBar)
        }
    }

    override fun initData() {
    }

    override fun startObserve() {
    }

}